{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{php echo createWebUrl('lt_points',array('themeid'=>$themeid));}" >积分记录</a></li>
    </ul>
    <div class="panel panel-info">
        <div class="panel-heading">筛选 共{$total}条</div>
        <div class="panel-body">
            <form action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="{$do}" />
                <input type="hidden" name="ac" value="search" />
                <input type="hidden" name="themeid" value="{$themeid}" />
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
                    <div class="col-sm-9 col-xs-9 col-md-9">
                        <input class="form-control" name="nickname" placeholder="输入微信昵称" type="text" value="{$_P['nickname']}">
                    </div>
                </div>
                <div class="form-group clearfix">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">浏览时间</label>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        {php echo view_form_field_daterange('createtime', array('start' => $start_day, 'end' => $end_day));}
                    </div>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                    </div>
                </div>
            </form>
        </div>
    </div>
    {if $ac == "display"}
<!--    <div class="panel panel-info">-->
<!--        <div class="panel-heading">当前数量： {$page_total}</div>-->
<!--    </div>-->
    {/if}
        <!--  列表框  -->
        {if $ac =='display' || $ac =='search'}
        <div class="panel panel-default">
        <div class="panel-body table-responsive" style="overflow:inherit">
            <table class="table table-hover">
                <thead class="navbar-inner">
                <tr>
                    <th width="50">ID</th>
                    <th>客户头像</th>
                    <th>微信昵称</th>
                    <th>姓名</th>
                    <th>电话</th>
                    <th>类型</th>
                    <th>积分</th>
                    <th>时间</th>
                    <th style="width:80px; text-align:right;">操作</th>
                </tr>
                </thead>
                <tbody>
                {loop $list $row}
                <tr>
                    <td><b>{$row['p_id']}</b></td>
                    <td>
                        <img src="{php echo tomedia($row['avatar']);}" width="28" style="border-radius: 3px;">
                    </td>
                    <td>
                        <a href="{php echo createWebUrl($do, array('themeid'=>$themeid, 'uid' => $row['uid']));}">{$row['nickname']}</a>
                    </td>

                    <td>
                        <a href="{php echo createWebUrl($do, array('themeid'=>$themeid, 'uid' => $row['uid']));}">{$row['username']}</a>
                    </td>
                    <td>
                        {$row['mobile']}
                    </td>
                    <td>
                        {if $row['op_type']=='pointsquan'}
                        分享到朋友圈
                        {elseif $row['op_type']=='pointsqun'}
                        分享到微信群
                        {elseif $row['op_type']=='pointsview'}
                        好友到访
                        {elseif $row['op_type']=='pointsselfbw'}
                        霸王抢下单(本人)
                        {elseif $row['op_type']=='pointsselfzc'}
                        下单(本人)
                        {elseif $row['op_type']=='pointsfriendbw'}
                        霸王抢下单(好友)
                        {elseif $row['op_type']=='pointsfriendzc'}
                        下单(好友)
                        {else}
                        管理员扣除
                        {/if}
                    </td>
                    <td>
                        {if $row['type']==1}+{/if}{$row['op_num']}
                    </td>
                    <td>{$row['created_at']}</td>
                    <td style="text-align:right; overflow:visible;">
                        {if $row['type']==1}
                        <div class="btn-group">
                            <a  class="btn btn-danger btn-sm" onclick="delPoints(this)" data-pid="{$row['p_id']}" data-themeid="{$themeid}"  title="扣除积分" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>
                        </div>
                        {/if}
                    </td>
                </tr>
                {/loop}

                </tbody>
            </table>
        </div>
        </div>

        {/if}
</div>

{if $ac =='display' || $ac =='search'}
{$pager}
{/if}
<script type="text/javascript">
    function drop_confirm(msg, url){
        if(confirm(msg)){
            window.location = url;
        }
    }
    // 扣除积分
    function delPoints(e) {
        let p_id = e.getAttribute("data-pid");
        let themeid = e.getAttribute("data-themeid");
        let ac = 'del';
        let postUrl ="{php echo createWebUrl('Lt_points');}";
        layer.msg('您确定该用户当前记录积分吗？',{
            btn:['确定','取消'],
            yes:function (index) {
                $.ajax({
                    url:postUrl,
                    dataType:'json',
                    method:'post',
                    data: {p_id:p_id,themeid:themeid,ac:ac},
                    success:function (e) {
                        let res = e.message;
                        let code = res.code;
                        let msg = res.msg;
                        if (code!=200){
                            layer.msg(msg);
                        }else{
                            layer.msg(msg);
                            location.reload();
                        }
                    },
                    fail:function (err) {
                        console.log(err)
                    }
                });
            }
        });
    }
</script>
